package edu.sandau.f210153.f21010108.service;

import edu.sandau.f210153.f21010108.model.Product;
import edu.sandau.f210153.f21010108.repository.ProductRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Component;

import java.util.List;
@Component
public class ProductService {
    @Autowired
    private ProductRepository productRepository;
    public List<Product> getAll(Product product) {
        return productRepository.findAll(Example.of(product));
    }

    public Product get(Long id) {
        return productRepository.getReferenceById(id);
    }

    public void delete(Long id){
        productRepository.deleteById(id);
    }
    public void save(Product s){
        productRepository.save(s);
    }


}